<template>
	<view class="container">
		<image src="../../static/bg2.png" class="" style="width: 100%; height: auto; display: block;" mode="widthFix">
		</image>
		<view class="wap-content">
			<view class="wap-content-item">

				<view class="question-title">针对本院，请留下您宝贵的意见</view>

				<view>
					<textarea v-model="suggestions" placeholder="这是一个意见箱，居民可以在这里提出对医院的意见"
						style="width: 90%;"></textarea>
				</view>

				<button class="submit-button"
					style="color:#ffffff;backgroundColor:#1e90f7;borderColor:#1e90f7;border-radius: 25px;width: 90%;margin-top: 20px;height: 50px;line-height: 50px;"
					type="primary" @click="submitSurvey">立即提交</button>
			</view>
		</view>
	</view>


	</view>
</template>

<script>
	import {
		postFeedback,
		postSurvey
	} from "@/api/api";
	export default {
		data() {
			return {
				suggestions: '',
				id: ''
			};
		},
		created() {
			// 添加两个随机的题目
			// this.addRandomQuestions(2);
			this.id = this.$route.query.id ? this.$route.query.id : "";
			console.log(this.id)


		},
		methods: {

			submitSurvey() {
				const formData = {
					// id: this.id,

					resident_name: "微信用户",
					idcardnum: '',
					content: this.suggestions
				};



				console.log(formData);

				postFeedback(formData)
					.then(res => {
						console.log('登录2' + JSON.stringify(res));
						// 在这里处理获取到的结果
						if (res.status === 1) {
							uni.showToast({
								title: '提交成功',
								icon: 'success',
								duration: 2000
							});
						} else {
							uni.showToast({
								title: res.msg || '提交失败',
								icon: 'none',
								duration: 2000
							});
						}
					})
					.catch(error => {
						console.error('请求出错：', error);
						// 在这里处理错误情况
					});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.container {
		background: linear-gradient(to bottom, #9dceff, #52acfd);
		background-size: 100% 100%;
		overflow: hidden;
		height: 100%;
	}

	.topimg {
		width: 100%;
		height: auto;
	}

	.wap-content {
		background-size: 100% 100%;
		background: linear-gradient(to bottom, #9dceff, #52acfd);
		padding: 0 4.3% 150px 4.3%;
		height: 500px;

	}

	.wap-content-item {
		background-color: #fff;
		padding: 0 20px 50px 20px;
	}

	.question {
		margin-bottom: 20px;

		.question-title {
			padding: 10px 0;
		}
	}

	.star-rating {
		margin-top: 10px;


	}

	textarea {
		height: 100px;
		margin-top: 10px;
		padding: 10px;
		border: 1px solid #ccc;
		border-radius: 5px;
	}

	/* 样式 */
	.option-button {
		background-color: #f2f6f8;
		border-radius: 20px;
		padding: 10px 20px;
		margin-bottom: 10px;
		// cursor: pointer;
		// display: flex;
		// align-items: center;
	}

	.selected {
		background-color: #1e90f7;
		color: #ffffff;
		justify-content: space-between;
	}
</style>